package com.sfzd5.UI;

import com.google.gson.Gson;
import com.itextpdf.text.DocumentException;
import com.sfzd5.UI.answersheet.*;
import com.sfzd5.aiclassroom.modle.ExamQuestionsInfo;
import com.sfzd5.exam.helplibrary.exam.ExamInof;
import com.sfzd5.exam.helplibrary.exam.MakePage;
import com.sfzd5.exam.helplibrary.exam.Page;
import com.sfzd5.exam.helplibrary.exam.PdfHelper;
import com.sfzd5.exam.helplibrary.exam.answersheet.*;
import org.apache.commons.io.FileUtils;

import javax.swing.*;
import javax.swing.border.TitledBorder;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreePath;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class CreateAnswerSheetDialog extends JDialog {
    private JPanel contentPane;
    private JButton 打印输出button;
    private JButton buttonCancel;
    private JButton 添加选择题区块Button;
    private JButton 添加填空题区块Button;
    private JButton 添加论述题区块Button;
    private JTree qTree;
    private JPanel sheet_panel;
    private JLabel lb_msg;
    private JButton 应用变更Button;
    private JButton 添加论述Button;
    private JButton 添加填空Button;
    private JButton 添加论述题Button;
    private JButton 添加填空题Button;
    private JButton 添加选择题Button;
    private JPanel editPanel;
    private JScrollPane editScroll;
    private JButton 编辑Button;
    private JButton 保存退出JsonButton;

    private boolean _isOk = false;

    public boolean isOk() {
        return _isOk;
    }

    boolean isEdit = false;
    AnswerSheetQuestion editAnswerSheetQuestion = null;

    ExamInof examInof;
    ExamQuestionsInfo exam;
    DefaultMutableTreeNode treeRoot;
    DefaultTreeModel defaultTreeModel;

    public ExamInof getExamInof() {
        return examInof;
    }

    File pdfFilePath;
    File kFile;

    public CreateAnswerSheetDialog(ExamQuestionsInfo exam) {
        this.exam = exam;

        //查询是否创建了答题卡信息
        pdfFilePath = new File(HomeWorkManager.examDir, String.valueOf(exam.id));
        if (!pdfFilePath.exists())
            pdfFilePath.mkdir();

        kFile = new File(pdfFilePath, exam.id + ".json");
        if (kFile.exists()) {
            try {
                String examInfoJson = FileUtils.readFileToString(kFile, "utf-8");
                examInof = new Gson().fromJson(examInfoJson, ExamInof.class);
                examInof.cleanAreaList();
            } catch (IOException e1) {
                e1.printStackTrace();
            }
        } else {
            examInof = exam.toExamInfo();
        }

        treeRoot = new DefaultMutableTreeNode(examInof);
        defaultTreeModel = new DefaultTreeModel(treeRoot);
        qTree.setModel(defaultTreeModel);
        TreePath path = new TreePath(treeRoot);
        qTree.setSelectionPath(path);

        setContentPane(contentPane);
        setModal(true);
        //getRootPane().setDefaultButton(打印输出button);

        打印输出button.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                print();
            }
        });

        buttonCancel.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                onCancel();
            }
        });

        addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                onCancel();
            }
        });

        //设置而已管理器
        VerticalFlowLayout vfl1 = new VerticalFlowLayout();
        vfl1.setVGap(10);
        sheet_panel.setLayout(vfl1);
        VerticalFlowLayout vfl = new VerticalFlowLayout();
        vfl.setVGap(10);
        editPanel.setLayout(vfl);

        应用变更Button.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                int count = editPanel.getComponentCount();
                if (count > 0) {
                    Object obj = editPanel.getComponent(0);

                    if (obj instanceof AreaEditBar) {
                        addArea(((AreaEditBar) obj).getArea());
                    } else if (obj instanceof BlankEditBar) {
                        List<BlankInfo> bs = new ArrayList<>();
                        for (int i = 0; i < count; i++) {
                            obj = editPanel.getComponent(i);
                            bs.add(((BlankEditBar) obj).getBlankInfo());
                        }
                        if (!isEdit)
                            addBlankInfo(bs);
                        else
                            ((BlankAnswerSheetQuestion) editAnswerSheetQuestion).updateInfoJson();

                    } else if (obj instanceof ChoiceEditBar) {
                        List<AnswerSheetQuestion> cs = new ArrayList<>();
                        for (int i = 0; i < count; i++) {
                            obj = editPanel.getComponent(i);
                            cs.add(((ChoiceEditBar) obj).getChoiceQuestion());
                        }
                        if (!isEdit) {
                            addQuestion(cs);
                        }
                    } else if (obj instanceof ExpoundChildEditBar) {
                        List<ExpoundChildQuestion> es = new ArrayList<>();
                        for (int i = 0; i < count; i++) {
                            obj = editPanel.getComponent(i);
                            ExpoundChildQuestion eq = ((ExpoundChildEditBar) obj).getExpoundChildQuestion();
                            es.add(eq);
                        }
                        if (!isEdit) {
                            addExpoundChildQuestion(es);
                        } else {
                            ((ExpoundAnswerSheetQuestion) editAnswerSheetQuestion).updateInfoJson();
                        }
                    } else {
                        lb_msg.setText("未知错误");
                    }

                    qTree.expandPath(qTree.getSelectionPath());
                    qTree.updateUI();

                    editPanel.removeAll();
                    editPanel.updateUI();
                    editScroll.updateUI();

                    restPdf();

                }
            }
        });

        添加选择题区块Button.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                isEdit = false;
                addAreaEditBar(Area.AreaType.Choice);
            }
        });

        添加填空题区块Button.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                isEdit = false;
                addAreaEditBar(Area.AreaType.Blank);
            }
        });
        添加论述题区块Button.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                isEdit = false;
                addAreaEditBar(Area.AreaType.Expound);
            }
        });
        添加选择题Button.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                String nstr = JOptionPane.showInputDialog("输入要建立的选择题个数：");
                try {
                    int n = Integer.parseInt(nstr);
                    editPanel.removeAll();
                    for (int i = 0; i < n; i++)
                        editPanel.add(new ChoiceEditBar(new ChoiceAnswerSheetQuestion()));
                    editPanel.updateUI();
                    isEdit = false;
                } catch (NumberFormatException ne) {

                }
            }
        });
        添加填空题Button.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                String nstr = JOptionPane.showInputDialog("输入要该填空题的空格个数：");
                try {
                    addAreaEditBar(Area.AreaType.Blank);
                    int n = Integer.parseInt(nstr);
                    editPanel.removeAll();
                    for (int i = 0; i < n; i++)
                        editPanel.add(new BlankEditBar(new BlankInfo()));
                    editPanel.updateUI();
                    isEdit = false;
                } catch (NumberFormatException ne) {

                }
            }
        });
        添加论述题Button.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                String nstr = JOptionPane.showInputDialog("输入论述题的小题个数：");
                try {
                    addAreaEditBar(Area.AreaType.Blank);
                    int n = Integer.parseInt(nstr);
                    editPanel.removeAll();
                    for (int i = 0; i < n; i++)
                        editPanel.add(new ExpoundChildEditBar(new ExpoundChildQuestion()));
                    editPanel.updateUI();
                    isEdit = false;
                } catch (NumberFormatException ne) {

                }
            }
        });

        添加填空Button.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                addAnswerSheetQuestionEditBar(new BlankEditBar(new BlankInfo()));
                isEdit = false;
            }
        });

        添加论述Button.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                addAnswerSheetQuestionEditBar(new ExpoundChildEditBar(new ExpoundChildQuestion()));
                isEdit = false;
            }
        });

        for (Area area : examInof.areaList) {
            if (area.answerSheetQuestionList.size() > 0) {
                DefaultMutableTreeNode an = new DefaultMutableTreeNode(area);
                addNode(treeRoot, an);

                if (area.areaType == Area.AreaType.Choice) {
                    for (AnswerSheetQuestion c : area.answerSheetQuestionList) {
                        addNode(an, new DefaultMutableTreeNode(c));
                    }
                } else if (area.areaType == Area.AreaType.Blank) {
                    for (AnswerSheetQuestion c : area.answerSheetQuestionList) {
                        BlankAnswerSheetQuestion bq = (BlankAnswerSheetQuestion) c;

                        DefaultMutableTreeNode pn = new DefaultMutableTreeNode(bq);
                        addNode(an, pn);
                        for (BlankInfo b : bq.getBlankInfoList()) {
                            addNode(pn, new DefaultMutableTreeNode(b));
                        }
                    }
                } else if (area.areaType == Area.AreaType.Expound) {
                    for (AnswerSheetQuestion c : area.answerSheetQuestionList) {
                        ExpoundAnswerSheetQuestion bq = (ExpoundAnswerSheetQuestion) c;
                        DefaultMutableTreeNode pn = new DefaultMutableTreeNode(bq);
                        addNode(an, pn);
                        for (ExpoundChildQuestion b : bq.getChildQuestionList()) {
                            addNode(pn, new DefaultMutableTreeNode(b));
                        }
                    }
                }
            }
        }

        qTree.expandPath(path);
        restPdf();

        编辑Button.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                TreePath selectPath = qTree.getSelectionPath();
                DefaultMutableTreeNode node = (DefaultMutableTreeNode) selectPath.getLastPathComponent();
                Object obj = node.getUserObject();
                if (obj instanceof Area) {
                    Area area = (Area) obj;
                    if (area.areaType == Area.AreaType.Choice) {
                        System.out.println(area.answerSheetQuestionList.size());
                        editPanel.removeAll();
                        for (AnswerSheetQuestion q : area.answerSheetQuestionList)
                            editPanel.add(new ChoiceEditBar((ChoiceAnswerSheetQuestion) q));
                        editPanel.updateUI();
                        isEdit = true;
                    }
                } else if (obj instanceof BlankAnswerSheetQuestion) {
                    BlankAnswerSheetQuestion bq = (BlankAnswerSheetQuestion) obj;
                    System.out.println(bq.getBlankInfoList().size());
                    addAreaEditBar(Area.AreaType.Blank);
                    editPanel.removeAll();
                    for (BlankInfo bi : bq.getBlankInfoList())
                        editPanel.add(new BlankEditBar(bi));
                    editPanel.updateUI();
                    isEdit = true;
                    editAnswerSheetQuestion = bq;
                } else if (obj instanceof ExpoundAnswerSheetQuestion) {
                    ExpoundAnswerSheetQuestion eq = (ExpoundAnswerSheetQuestion) obj;
                    System.out.println(eq.getChildQuestionList().size());
                    addAreaEditBar(Area.AreaType.Blank);
                    editPanel.removeAll();
                    for (ExpoundChildQuestion cq : eq.getChildQuestionList())
                        editPanel.add(new ExpoundChildEditBar(cq));
                    editPanel.updateUI();
                    isEdit = true;
                    editAnswerSheetQuestion = eq;
                }
            }
        });
        保存退出JsonButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                File kFile = new File(pdfFilePath, examInof.taskId + ".json");
                String examInfoJson = new Gson().toJson(examInof);
                try {
                    FileUtils.writeStringToFile(kFile, examInfoJson, "utf-8");
                } catch (IOException ioException) {
                    ioException.printStackTrace();
                }
                _isOk = true;
                dispose();
            }
        });
    }

    void restPdf() {
        sheet_panel.removeAll();
        MakePage makePage = new MakePage();
        examInof.pages = makePage.makePages(examInof);
        for (Page p : examInof.pages) {
            makePage.drawPage(examInof, p, 123, 1);
            BufferedImage bi = makePage.getImage();
            JImage image = new JImage();
            image.setImage(bi);
            image.setText(String.format("第 %d 页", p.pageId + 1));
            sheet_panel.add(image);
            makePage.close();
            makePage = new MakePage();
        }
        sheet_panel.updateUI();
        if (examInof.pages.size() > 1) {
            JOptionPane.showMessageDialog(null, "答题卡内容超过一页！本系统只能处理一页的答题卡！", "警告", JOptionPane.INFORMATION_MESSAGE);
        }
    }

    void addAreaEditBar(Area.AreaType t) {
        Area area = new Area();
        area.areaType = t;
        addAnswerSheetQuestionEditBar(new AreaEditBar(area));
    }

    void addAnswerSheetQuestionEditBar(AnswerSheetQuestionEditBar bar) {
        editPanel.removeAll();
        editPanel.add(bar);
        editPanel.updateUI();
    }

    //打印输出
    private void print() {
        try {
            FileUtils.write(kFile, new Gson().toJson(examInof), "utf-8");
        } catch (IOException ee) {
            ee.printStackTrace();
        }

        for (int i = 1; i < 50; i++) {
            try {
                File pdfFile = new File(pdfFilePath, exam.id + "_" + i + ".pdf");
                PdfHelper pdfHelper = new PdfHelper(pdfFile);
                pdfHelper.addPages(examInof, exam.id, i);
                pdfHelper.save();
            } catch (DocumentException | IOException ee) {
                ee.printStackTrace();
            }
        }

        lb_msg.setText("PDF已生成");
        try {
            Desktop.getDesktop().open(pdfFilePath);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    //关闭窗口
    private void onCancel() {
        _isOk = false;
        dispose();
    }

    public void addExpoundChildQuestion(List<ExpoundChildQuestion> es) {
        if (!qTree.isSelectionEmpty()) {
            DefaultMutableTreeNode node = (DefaultMutableTreeNode) qTree.getLastSelectedPathComponent();
            addExpoundChildQuestion(node, es);
        } else {
            lb_msg.setText("必须先选中相关题目");
        }
    }

    public void addExpoundChildQuestion(DefaultMutableTreeNode node, List<ExpoundChildQuestion> es) {
        Object obj = node.getUserObject();
        if (obj instanceof ExpoundAnswerSheetQuestion) {
            ExpoundAnswerSheetQuestion q = (ExpoundAnswerSheetQuestion) obj;
            for (ExpoundChildQuestion e : es) {
                if (!q.getChildQuestionList().contains(e)) {
                    q.getChildQuestionList().add(e);
                    q.setChildQuestionList(q.getChildQuestionList());
                }
                addNode(node, new DefaultMutableTreeNode(e));
            }
            return;
        } else if (obj instanceof Area) {
            Area a = (Area) obj;
            if (a.areaType == Area.AreaType.Expound) {
                ExpoundAnswerSheetQuestion q = new ExpoundAnswerSheetQuestion();
                a.answerSheetQuestionList.add(q);
                DefaultMutableTreeNode pn = new DefaultMutableTreeNode(q);
                addNode(node, pn);
                for (ExpoundChildQuestion e : es) {
                    if (!q.getChildQuestionList().contains(e)) {
                        q.getChildQuestionList().add(e);
                        q.setChildQuestionList(q.getChildQuestionList());
                    }
                    addNode(pn, new DefaultMutableTreeNode(e));
                }
                return;
            }
        }
    }

    public void addBlankInfo(List<BlankInfo> bs) {
        if (!qTree.isSelectionEmpty()) {
            DefaultMutableTreeNode node = (DefaultMutableTreeNode) qTree.getLastSelectedPathComponent();
            addBlankInfo(node, bs);
        } else {
            lb_msg.setText("必须先选中相关题目");
        }
    }

    public void addBlankInfo(DefaultMutableTreeNode node, List<BlankInfo> bs) {
        Object obj = node.getUserObject();
        if (obj instanceof BlankAnswerSheetQuestion) {
            BlankAnswerSheetQuestion q = (BlankAnswerSheetQuestion) obj;
            for (BlankInfo b : bs) {
                if (!q.getBlankInfoList().contains(b)) {
                    q.getBlankInfoList().add(b);
                    q.setBlankInfoList(q.getBlankInfoList());
                }
                addNode(node, new DefaultMutableTreeNode(b));
            }
            return;
        } else if (obj instanceof Area) {
            Area a = (Area) obj;
            if (a.areaType == Area.AreaType.Blank) {

                BlankAnswerSheetQuestion q = new BlankAnswerSheetQuestion();
                a.answerSheetQuestionList.add(q);
                DefaultMutableTreeNode pn = new DefaultMutableTreeNode(q);
                addNode(node, pn);

                for (BlankInfo b : bs) {
                    if (!q.getBlankInfoList().contains(b)) {
                        q.getBlankInfoList().add(b);
                        q.setBlankInfoList(q.getBlankInfoList());
                    }
                    addNode(pn, new DefaultMutableTreeNode(b));
                }
                return;
            }
        }
    }

    /**
     * 可添加 选择题、填空题、论述题
     *
     * @param cs
     */
    public void addQuestion(List<AnswerSheetQuestion> cs) {
        if (!qTree.isSelectionEmpty()) {
            DefaultMutableTreeNode node = (DefaultMutableTreeNode) qTree.getLastSelectedPathComponent();
            addQuestion(node, cs);
        } else {
            lb_msg.setText("必须先选中相关题目");
        }
    }

    public void addQuestion(DefaultMutableTreeNode node, List<AnswerSheetQuestion> cs) {
        Object obj = node.getUserObject();
        if (obj instanceof Area) {
            Area a = (Area) obj;
            AnswerSheetQuestion tc = cs.get(0);
            if (a.areaType == tc.getTyep()) {
                for (AnswerSheetQuestion c : cs) {
                    if (!a.answerSheetQuestionList.contains(c)) a.answerSheetQuestionList.add(c);
                    addNode(node, new DefaultMutableTreeNode(c));
                }
                return;
            }
        }
    }

    public void addArea(Area a) {
        if (!examInof.areaList.contains(a)) examInof.areaList.add(a);
        addNode(treeRoot, new DefaultMutableTreeNode(a));
    }

    void addNode(DefaultMutableTreeNode p, DefaultMutableTreeNode n) {
        p.add(n);
    }

    {
// GUI initializer generated by IntelliJ IDEA GUI Designer
// >>> IMPORTANT!! <<<
// DO NOT EDIT OR ADD ANY CODE HERE!
        $$$setupUI$$$();
    }

    /**
     * Method generated by IntelliJ IDEA GUI Designer
     * >>> IMPORTANT!! <<<
     * DO NOT edit this method OR call it in your code!
     *
     * @noinspection ALL
     */
    private void $$$setupUI$$$() {
        contentPane = new JPanel();
        contentPane.setLayout(new com.intellij.uiDesigner.core.GridLayoutManager(2, 1, new Insets(10, 10, 10, 10), -1, -1));
        final JPanel panel1 = new JPanel();
        panel1.setLayout(new com.intellij.uiDesigner.core.GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1));
        contentPane.add(panel1, new com.intellij.uiDesigner.core.GridConstraints(1, 0, 1, 1, com.intellij.uiDesigner.core.GridConstraints.ANCHOR_CENTER, com.intellij.uiDesigner.core.GridConstraints.FILL_BOTH, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_SHRINK | com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_GROW, 1, null, null, null, 0, false));
        final com.intellij.uiDesigner.core.Spacer spacer1 = new com.intellij.uiDesigner.core.Spacer();
        panel1.add(spacer1, new com.intellij.uiDesigner.core.GridConstraints(0, 0, 1, 1, com.intellij.uiDesigner.core.GridConstraints.ANCHOR_CENTER, com.intellij.uiDesigner.core.GridConstraints.FILL_HORIZONTAL, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false));
        final JPanel panel2 = new JPanel();
        panel2.setLayout(new com.intellij.uiDesigner.core.GridLayoutManager(1, 5, new Insets(0, 0, 0, 0), -1, -1));
        panel1.add(panel2, new com.intellij.uiDesigner.core.GridConstraints(0, 1, 1, 1, com.intellij.uiDesigner.core.GridConstraints.ANCHOR_CENTER, com.intellij.uiDesigner.core.GridConstraints.FILL_BOTH, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_SHRINK | com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_GROW, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_SHRINK | com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
        打印输出button = new JButton();
        打印输出button.setText("打印输出");
        panel2.add(打印输出button, new com.intellij.uiDesigner.core.GridConstraints(0, 2, 1, 1, com.intellij.uiDesigner.core.GridConstraints.ANCHOR_CENTER, com.intellij.uiDesigner.core.GridConstraints.FILL_HORIZONTAL, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_SHRINK | com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_GROW, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
        buttonCancel = new JButton();
        buttonCancel.setText("取消");
        panel2.add(buttonCancel, new com.intellij.uiDesigner.core.GridConstraints(0, 4, 1, 1, com.intellij.uiDesigner.core.GridConstraints.ANCHOR_CENTER, com.intellij.uiDesigner.core.GridConstraints.FILL_HORIZONTAL, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_SHRINK | com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_GROW, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
        lb_msg = new JLabel();
        lb_msg.setText("信息");
        panel2.add(lb_msg, new com.intellij.uiDesigner.core.GridConstraints(0, 0, 1, 1, com.intellij.uiDesigner.core.GridConstraints.ANCHOR_WEST, com.intellij.uiDesigner.core.GridConstraints.FILL_NONE, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
        应用变更Button = new JButton();
        应用变更Button.setText("应用变更");
        panel2.add(应用变更Button, new com.intellij.uiDesigner.core.GridConstraints(0, 1, 1, 1, com.intellij.uiDesigner.core.GridConstraints.ANCHOR_CENTER, com.intellij.uiDesigner.core.GridConstraints.FILL_NONE, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_SHRINK | com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_GROW, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_SHRINK | com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
        保存退出JsonButton = new JButton();
        保存退出JsonButton.setText("保存退出");
        panel2.add(保存退出JsonButton, new com.intellij.uiDesigner.core.GridConstraints(0, 3, 1, 1, com.intellij.uiDesigner.core.GridConstraints.ANCHOR_CENTER, com.intellij.uiDesigner.core.GridConstraints.FILL_HORIZONTAL, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_SHRINK | com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_GROW, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
        final JPanel panel3 = new JPanel();
        panel3.setLayout(new BorderLayout(0, 0));
        contentPane.add(panel3, new com.intellij.uiDesigner.core.GridConstraints(0, 0, 1, 1, com.intellij.uiDesigner.core.GridConstraints.ANCHOR_CENTER, com.intellij.uiDesigner.core.GridConstraints.FILL_BOTH, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_SHRINK | com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_GROW, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_SHRINK | com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
        final JToolBar toolBar1 = new JToolBar();
        toolBar1.setFloatable(false);
        panel3.add(toolBar1, BorderLayout.NORTH);
        添加选择题区块Button = new JButton();
        添加选择题区块Button.setText("添加选择题区块");
        toolBar1.add(添加选择题区块Button);
        添加填空题区块Button = new JButton();
        添加填空题区块Button.setText("添加填空题区块");
        toolBar1.add(添加填空题区块Button);
        添加论述题区块Button = new JButton();
        添加论述题区块Button.setText("添加论述题区块");
        toolBar1.add(添加论述题区块Button);
        添加选择题Button = new JButton();
        添加选择题Button.setText("添加选择题");
        toolBar1.add(添加选择题Button);
        添加填空题Button = new JButton();
        添加填空题Button.setText("添加填空题");
        toolBar1.add(添加填空题Button);
        添加论述题Button = new JButton();
        添加论述题Button.setText("添加论述题");
        toolBar1.add(添加论述题Button);
        添加填空Button = new JButton();
        添加填空Button.setText("添加填空");
        toolBar1.add(添加填空Button);
        添加论述Button = new JButton();
        添加论述Button.setText("添加论述");
        toolBar1.add(添加论述Button);
        编辑Button = new JButton();
        编辑Button.setText("编辑");
        toolBar1.add(编辑Button);
        final JSplitPane splitPane1 = new JSplitPane();
        splitPane1.setLastDividerLocation(-1);
        splitPane1.setMinimumSize(new Dimension(300, 79));
        splitPane1.setOrientation(0);
        splitPane1.setPreferredSize(new Dimension(300, 424));
        panel3.add(splitPane1, BorderLayout.EAST);
        final JPanel panel4 = new JPanel();
        panel4.setLayout(new BorderLayout(0, 0));
        splitPane1.setLeftComponent(panel4);
        panel4.setBorder(BorderFactory.createTitledBorder(null, "题目列表", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null));
        final JScrollPane scrollPane1 = new JScrollPane();
        scrollPane1.setVerticalScrollBarPolicy(20);
        panel4.add(scrollPane1, BorderLayout.CENTER);
        qTree = new JTree();
        scrollPane1.setViewportView(qTree);
        final JPanel panel5 = new JPanel();
        panel5.setLayout(new BorderLayout(0, 0));
        splitPane1.setRightComponent(panel5);
        final JPanel panel6 = new JPanel();
        panel6.setLayout(new BorderLayout(0, 0));
        panel5.add(panel6, BorderLayout.CENTER);
        panel6.setBorder(BorderFactory.createTitledBorder(null, "属性列表", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null));
        editScroll = new JScrollPane();
        panel6.add(editScroll, BorderLayout.CENTER);
        editPanel = new JPanel();
        editPanel.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
        editScroll.setViewportView(editPanel);
        final JScrollPane scrollPane2 = new JScrollPane();
        panel3.add(scrollPane2, BorderLayout.CENTER);
        sheet_panel = new JPanel();
        sheet_panel.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
        scrollPane2.setViewportView(sheet_panel);
    }

    /**
     * @noinspection ALL
     */
    public JComponent $$$getRootComponent$$$() {
        return contentPane;
    }
}
